D			[0-9]
L			[a-zA-Z_]

%{
#include <stdio.h>
#include "YaccParser.h"



#include "y.tab.h"
int check_type();
%}

%%

{L}({L}|{D})*			{ return (check_type());}

"{%"					{ return INCLUDE_START;}
"%}"					{ return INCLUDE_END;}
"%%"					{ ;}	//return BOUNDER
"%token"				{ return TOKEN;}
"%union"				{ return UNION;}
"%type"					{ return TYPE;}
"%nonassoc"				{ return NONASSOC;}
"%start"				{ return START; }
"|"						{ return '|';}
"'.'"					{ return CHARACTER;}
";"						{ return ';';}

[ \t\v\n\f]				{ ;}

%%


#include "symbol_table/SymbolTablePool.h"
#include "YaccParser.h"
int yywrap()
{
	return(1);
}

int check_type()
{
	SymbolTablePool & symbolTables = SymbolTablePool::getInstance();
	std::string tmp(yytext);
	
	SymbolBase * pSym = symbolTables.findSymbol(tmp);
	if(pSym == NULL)
	{
		pSym = new SymbolBase(tmp, SymbolBase::identifier);
		symbolTables.addSymbol(pSym);
		return IDENTIFIER;
	}

	yylval.pSym = pSym;
	return pSym->getSymbolType();
}
